Add MCP notifications/message for log streaming to clients#3484
Open
anushakolan wants to merge 3 commits intomainfrom
Open
Add MCP notifications/message for log streaming to clients#3484anushakolan wants to merge 3 commits intomainfrom
anushakolan wants to merge 3 commits intomainfrom
Conversation
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
previously approved these changes
May 1, 2026
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Left some suggestions for code reuse.
3b658ef to
e2a1ee8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for streaming server logs to MCP clients via notifications/message, enabling real-time log consumption after logging/setLevel is invoked.
Changes:
- Introduces MCP-specific logging components (
McpLogger,McpLoggerProvider,McpLogNotificationWriter) that emit logs as JSON-RPC notifications to stdout. - Centralizes MCP↔.NET log level mapping in
McpLogLevelConverterand wires it into dynamic log level handling. - Updates MCP stdio server to enable/disable log notifications based on
logging/setLeveland standardizes JSON-RPC version usage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/Telemetry/DynamicLogLevelProvider.cs | Switches MCP level parsing to shared converter. |
| src/Service/Program.cs | Registers MCP notification writer/provider and clears default log providers in MCP stdio mode. |
| src/Service.Tests/UnitTests/McpLogNotificationTests.cs | Adds unit tests around MCP logger/provider enabled behavior. |
| src/Core/Telemetry/McpLogLevelConverter.cs | Adds shared MCP↔.NET log level conversion utility. |
| src/Azure.DataApiBuilder.Mcp/Telemetry/McpLoggerProvider.cs | Adds logger provider that caches per-category MCP loggers. |
| src/Azure.DataApiBuilder.Mcp/Telemetry/McpLogger.cs | Adds ILogger implementation that forwards logs to MCP notifications. |
| src/Azure.DataApiBuilder.Mcp/Telemetry/McpLogNotificationWriter.cs | Adds stdout JSON-RPC notification writer + interface for toggling. |
| src/Azure.DataApiBuilder.Mcp/Model/McpStdioJsonRpcErrorCodes.cs | Introduces shared JSON-RPC version constant. |
| src/Azure.DataApiBuilder.Mcp/Core/McpStdioServer.cs | Enables notifications on logging/setLevel and uses shared JSON-RPC version constant. |
Comment on lines
+65
to
+69
| Stream stdout = Console.OpenStandardOutput(); | ||
| _writer = new StreamWriter(stdout, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)) | ||
| { | ||
| AutoFlush = true | ||
| }; |
Comment on lines
+101
to
+104
| lock (_lock) | ||
| { | ||
| _writer?.WriteLine(json); | ||
| } |
Comment on lines
+18
to
+26
| [TestMethod] | ||
| public void McpLogNotificationWriter_IsEnabledFalseByDefault() | ||
| { | ||
| // Arrange & Act | ||
| McpLogNotificationWriter writer = new(); | ||
|
|
||
| // Assert | ||
| Assert.IsFalse(writer.IsEnabled); | ||
| } |
Comment on lines
8
to
+13
| internal static class McpStdioJsonRpcErrorCodes | ||
| { | ||
| /// <summary> | ||
| /// JSON-RPC protocol version. | ||
| /// </summary> | ||
| public const string JSON_RPC_VERSION = "2.0"; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Aniruddh25
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
Enables MCP clients (like MCP Inspector, Claude Desktop, VS Code Copilot) to receive real-time log output via MCP
notifications/message.Related: #3274 (depends on PR #3419)
What is this change?
When
logging/setLevelis called with a level other than "none", logs are sent to MCP clients as JSON-RPC notifications:{ "jsonrpc": "2.0", "method": "notifications/message", "params": { "level": "info", "logger": "Azure.DataApiBuilder.Service.Startup", "data": "Starting Data API builder..." } }New files:
McpLogNotificationWriter.cs- Writes logs as MCP notifications to stdoutMcpLogger.cs/McpLoggerProvider.cs- ILogger implementation for .NET logging pipelineMcpLogNotificationTests.cs- Unit tests (8 tests)Modified files:
Program.cs- RegistersMcpNotificationWriterandMcpLoggerProviderfor MCP modeMcpStdioServer.cs- Enables notifications whenlogging/setLevelis calledHow was this tested?
logging/setLevelis sentNote
This PR targets
dev/anushakolan/set-log-level(PR #3419) as it depends on thelogging/setLevelimplementation.